package rowset;

import java.sql.SQLException;

import javax.sql.rowset.CachedRowSet;

import com.sun.rowset.CachedRowSetImpl;

public class DisconnectedRowset {
	public static void main(String[] args) {

		try {
			CachedRowSet cacheRS = new CachedRowSetImpl();

			// cacheRS.setUrl("jdbc:sqlserver://localhost:1433;databaseName=test;user=sa;password=sa");

			// hoac set user, pass ro rang hon
			cacheRS.setUrl("jdbc:sqlserver://BDK-PC;databaseName=Demo;");
			cacheRS.setUsername("sa");
			cacheRS.setPassword("123456");
			// sql
			cacheRS.setCommand("SELECT * FROM SINHVIEN");

			// execute
			cacheRS.execute();

			while (cacheRS.next()) {
				System.out.println(cacheRS.getString(1));
			}
		} catch (SQLException e) {
			e.printStackTrace();
		}
	}
}
